Skip to content

fixed billing issues#626

Merged
Ebube111 merged 1 commit into
stagingfrom
billing-fix
May 18, 2026
Merged

fixed billing issues#626
Ebube111 merged 1 commit into
stagingfrom
billing-fix

Conversation

@Ebube111

@Ebube111 Ebube111 commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • NEAR RPC now automatically switches between multiple endpoints when one is unavailable, improving reliability.
    • External API requests enforce timeout limits to prevent hanging requests.
    • Payment callback polling uses an improved stepped backoff strategy for better reliability.
  • Performance

    • Extended cache durations for static assets (robots.txt, sitemaps, and campaign pages) to reduce server load and improve response times.

Review Change Stack

@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
potlock-next-app Ready Ready Preview, Comment May 18, 2026 4:43am

Request Review

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR hardens reliability across external API calls, RPC failover, and polling retry logic while optimizing cache TTLs. Five API routes now enforce request timeouts via maxDuration and fetchWithTimeout helpers; NEAR RPC is refactored to support multi-endpoint failover with cooldown tracking; polling uses stepped backoff; and static asset cache headers and ISR revalidation timings are extended.

Changes

Reliability and Performance Hardening

Layer / File(s) Summary
API Request Timeout Enforcement
src/app/api/pinata/get-auth-key/route.ts, src/app/api/pingpay/create-checkout/route.ts, src/app/api/pingpay/create-project-checkout/route.ts, src/app/api/pingpay/session-status/route.ts, src/app/api/pingpay/verify-tx/route.ts
Five API routes export maxDuration = 15 and implement fetchWithTimeout helper with AbortController to abort outbound Pinata and PingPay requests after 10 seconds, preventing hanging external calls.
NEAR RPC Multi-Endpoint Failover
src/common/blockchains/near-protocol/client.ts
nearRpc is refactored from a single provider into a resilient selector maintaining multiple RPC endpoints, applying per-URL cooldown after failures, reordering preference by last successful index, and falling back through available providers before rethrowing the last error.
Stepped Backoff Polling Strategy
src/app/pingpay/callback/page.tsx
pollSessionStatus replaces fixed retry count with a generated delay schedule (delaysMs), waiting between status checks according to progressive backoff sequence.
Cache and Performance Tuning
src/pages/campaign/[campaignId]/index.tsx, src/pages/robots.txt.ts, src/pages/sitemap.xml.ts, src/middleware.ts
Cache-Control TTL extended for robots.txt and sitemap.xml; campaign page ISR revalidate adjusted to 3600s (success) / 600s (fallback); middleware restricted to /profile/:path* via route matcher; unused import removed.

Sequence Diagram(s)

sequenceDiagram
  participant Route as API Route
  participant FWT as fetchWithTimeout
  participant AC as AbortController
  participant Ext as External Service
  Route->>FWT: fetch with timeout config
  FWT->>AC: create controller
  FWT->>Ext: fetch with abort signal
  alt Request succeeds
    Ext-->>FWT: response
    FWT-->>Route: return response
  else Timeout fires
    AC->>AC: abort signal
    FWT->>Ext: cancel request
    Ext-->>FWT: AbortError
    FWT-->>Route: throw error
  end
  FWT->>FWT: finally clear timer
Loading
sequenceDiagram
  participant Code as Caller
  participant nearRpc as nearRpc.query
  participant queryNRpc as queryNearRpc
  participant Providers as RPC Providers
  Code->>nearRpc: query request
  nearRpc->>queryNRpc: route through selector
  queryNRpc->>queryNRpc: sort by last success, skip cooldown
  loop Try providers in order
    queryNRpc->>Providers: attempt RPC call
    alt Success
      Providers-->>queryNRpc: response
      queryNRpc->>queryNRpc: record success index
      queryNRpc-->>nearRpc: return response
    else Failure
      Providers-->>queryNRpc: error
      queryNRpc->>queryNRpc: mark unavailable, record failure
    end
  end
  queryNRpc-->>nearRpc: throw last error if all fail
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • PotLock/potlock-nextjs-app#623: Introduces the PingPay and verify-tx API routes that this PR now hardens with timeout enforcement and error handling.
  • PotLock/potlock-nextjs-app#541: Also modifies campaign page getStaticProps ISR revalidate behavior, overlapping with this PR's cache timing adjustments.
  • PotLock/potlock-nextjs-app#530: Related changes to campaign page ISR revalidate timings, directly relevant to this PR's cache optimization layer.

Poem

🐰 Timeouts and failovers, oh what a sight,
API requests abort when delays get tight,
NEAR RPC hops around with cooldown grace,
While cache TTLs give static files more space,
Reliability blooms in the spring debugging light!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fixed billing issues' is vague and does not clearly describe the primary changes in the changeset. Provide a more specific title that describes the main changes, such as 'Add request timeouts and retry logic to API routes' or 'Implement timeout handling and RPC failover mechanisms'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch billing-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Ebube111 Ebube111 merged commit 5d38375 into staging May 18, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant